#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
    int pid = 0;
    int i = 0;
    
    if( (pid = fork()) > 0 ) {
        printf("parrent = %d, ppid = %d, pgid = %d, sid = %d\n", 
            getpid(), getppid(), getpgrp(), getsid(getpid()));
        printf("new: %d\n", pid);
    } else if( pid == 0 ) {
        setsid();
        sleep(3);
        printf("child = %d, ppid = %d, pgid = %d, sid = %d\n", 
            getpid(), getppid(), getpgrp(), getsid(getpid()));
    } else {
        printf("fork error...\n");
    }  
    
    sleep(240);
    
    return 0;
}

